#include <REGX52.H>
#include <INTRINS.H>
void Delay1ms(int xms)		//@12.000MHz
{
	unsigned char i, j;
	while(xms--){
		i = 12;
	j = 169;
	do
	{
		while (--j);
	} while (--i);
	}
}
void main(){
	
	unsigned char LEDnum=0;
	P2=(P2&0x1f)|0x80;
	while(1){
		if(P3_1==0){
			Delay1ms(20);
			while(P3_1==0);
			Delay1ms(20);
			if(LEDnum>=8)
				LEDnum=0;
			P0=~(0x01<<LEDnum);
			LEDnum++;
		}
		if(P3_0==0){
			Delay1ms(20);
			while(P3_0==0);
			Delay1ms(20);
			if(LEDnum<=1)
				LEDnum=9;
			LEDnum--;
			P0=~(0x01<<(LEDnum-1));
		}
	}
}